package com.jiuwu.spring.eshop.respository;

import com.jiuwu.spring.eshop.db.entity.Member;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Transactional
public interface MemberRepository extends JpaRepository<Member,Integer> {

    @Modifying
    @Query(value = "update Member set memberFreeze = ?2 where memberID = ?1")
    void updateMemberInfo(Integer id,Integer freeze);


    Optional<Member> findByMemberNameEquals(String memberName);

    Page<Member> findAll(Pageable pageable);
}
